package com.maodou.android

import android.app.Application
import com.maodou.core.manager.GlobalStateManager
import com.maodou.core.utils.ActivityProvider
import com.maodou.core.utils.Logger
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltAndroidApp
class MaoDouApp : Application() {

    @Inject
    lateinit var globalState: GlobalStateManager
    
    @Inject
    lateinit var activityProvider: ActivityProvider

    override fun onCreate() {
        super.onCreate()
        GlobalScope.launch(Dispatchers.IO) {

            Logger.isLoggingEnabled = BuildConfig.DEBUG
            Logger.globalTagPrefix = "MaoDou"

            ActivityProvider.initialize(activityProvider)

            //获取一些本地配置 设置给全局状态使用  例如是否登录、token、用户信息等等
            globalState.initialize()

        }
    }
}